export {};

class Person {
    public name: string;
    private age: number;
    protected gender: boolean;
    constructor(name: string, age: number, gender?: boolean) {
        this.name = name;
        this.age = age;
        this.gender = gender;
    }
    sayHi(msg: string):void {
        console.log(`i am ${this.name}, ${this.age}岁`)
    }
}

const person = new Person('aaa', 18, false);
// 允许外部反问
person.name = 'asaaa';
// 不允许外部访问
// person.age = 19;
// 只允许在子类中访问
// person.gender = false;

class Boy extends Person {
    constructor(name: string, age: number) {
        super(name, age);
        console.log(this.gender)
    }
}

const boy = new Boy('lll', 19);